<?php

/**
 * PlayerTalent form base class.
 *
 * @method PlayerTalent getObject() Returns the current form's model object
 *
 * @package    raidpoints
 * @subpackage form
 * @author     David Driscoll
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BasePlayerTalentForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'          => new sfWidgetFormInputHidden(),
      'playerid'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Player'), 'add_empty' => false)),
      'talentgroup' => new sfWidgetFormInputText(),
      'active'      => new sfWidgetFormInputCheckbox(),
      'mainspec'    => new sfWidgetFormInputCheckbox(),
      'tankspec'    => new sfWidgetFormInputCheckbox(),
      'talentid'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Talent'), 'add_empty' => false)),
      'spec'        => new sfWidgetFormInputText(),
      'url'         => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'          => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'playerid'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Player'))),
      'talentgroup' => new sfValidatorInteger(),
      'active'      => new sfValidatorBoolean(array('required' => false)),
      'mainspec'    => new sfValidatorBoolean(array('required' => false)),
      'tankspec'    => new sfValidatorBoolean(array('required' => false)),
      'talentid'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Talent'))),
      'spec'        => new sfValidatorString(array('max_length' => 8)),
      'url'         => new sfValidatorString(array('max_length' => 255, 'required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'PlayerTalent', 'column' => array('playerid', 'talentgroup')))
    );

    $this->widgetSchema->setNameFormat('player_talent[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'PlayerTalent';
  }

}
